<?php
/**
 * Created by 784855684@qq.com.
 * Link: https://github.com/lichtung/wshore
 * User: linzh
 * Date: 7/12/17
 * Time: 11:12 AM
 */
declare(strict_types=1);

namespace {


    use application\service\library\socket\EventHandlerInterface;
    use application\service\library\socket\Message;
    use application\service\library\SocketServer;
    use PHPSocketIO\Socket;
    use Workerman\Connection\TcpConnection;

    require __DIR__ . '/../../wshore/engine.inc';

    class SocketEventHandler implements EventHandlerInterface
    {
        public function connect(Socket $clientServer, SocketServer $clientServerServer): bool
        {
            return true;
        }

        public function register(Message $message, Socket $clientServer, SocketServer $clientServerServer): bool
        {
            return true;
        }

        public function request(TcpConnection $connection, array $env, SocketServer $context)
        {
            echo "[request]";
            return false;
        }

        public function disconnect(Socket $clientServer, SocketServer $clientServerServer)
        {
            echo "[{$clientServer->id} disconnect]";
        }

        public function message(Message $message, Socket $clientServer, SocketServer $clientServerServer)
        {
        }
    }

    $server = new SocketServer();
    $server->setHandler(new SocketEventHandler());
    $server->start();

}